fix: add configurable safe-outputs URL sanitization policy for code-region-safe suggestion handling#39927
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…stion block corruption Safe-output URL sanitization (protocol filtering and domain filtering) now uses applyToNonCodeRegions so that content inside fenced code blocks — including GitHub suggestion blocks — is never rewritten. Previously, sanitizeUrlProtocols and sanitizeUrlDomains were applied to the full output string, which could corrupt apply-ready patch payloads inside ```suggestion fences (e.g. custom-protocol docs crosslinks). Fixes #39793 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes safe-output URL sanitization so it does not rewrite content inside fenced code blocks (including GitHub ```suggestion fences), preventing suggestion patch payload corruption while continuing to sanitize URLs in prose.
Changes:
- Apply
sanitizeUrlProtocolsandsanitizeUrlDomainsviaapplyToNonCodeRegionsso fenced/inline code is preserved verbatim. - Add regression tests covering protocol and domain sanitization behavior for generic fenced blocks and
suggestionblocks. - Adjust a header comment in the setup CLI install script.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/sanitize_content_core.cjs | Routes URL protocol/domain sanitization through applyToNonCodeRegions to avoid rewriting fenced code content. |
| actions/setup/js/sanitize_content.test.cjs | Adds regression tests ensuring code fences (including suggestion) are preserved while prose is still sanitized. |
| actions/setup-cli/install.sh | Updates a sync note comment (currently becomes self-referential; see review comment). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 1
| set +o histexpand | ||
|
|
||
| # Kept in sync with install-gh-aw.sh — edit that file, then copy to this path. | ||
| # Kept in sync with actions/setup-cli/install.sh — edit this file, then copy to that path. |
|
@lpcox review please |
|
@copilot review all comments and address unresolved review feedback.
|
|
Please fix the self-referential sync note in actions/setup-cli/install.sh and push a follow-up commit.
|
|
@copilot review all comments and address unresolved review feedback. Please summarize the remaining blockers and next steps so this branch can move forward.
|
|
@copilot review all comments and address unresolved review feedback.
|
|
\n@copilot review all comments and address unresolved review feedback.\n\npr-sous-chef: fix the self-referential install.sh comment and reply to the unresolved review comment.
|
|
@copilot review all comments and address unresolved review feedback.
|
|
`
|
|
`
|
|
@copilot add a front matter field to define the URL escaping policy at the safe-outputs level safe-outputs: Current mode is "allowed-only", new mode for code region is "allowed-or-code-region" Must support import shared agentic workflows |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in 33928f0 (plus follow-ups 521697f and 8ca74cb):
|
|
@copilot recompile |
Ran |
|
|
``
|
Safe-output URL sanitization is now policy-driven at the
safe-outputsfrontmatter level, so workflows can choose between strict URL sanitization everywhere and preserving URLs inside code regions (including GitHubsuggestionfences) to avoid patch corruption.Changes
safe-outputs.urlswith supported values:allowed-only(default): sanitize URLs across all content regionsallowed-or-code-region: sanitize prose while preserving fenced/inline code regionssanitize_content_core.cjs/sanitize_content.cjs:GH_AW_SAFE_OUTPUTS_URLSsuggestion/code-region payloads only whenallowed-or-code-regionis selectedsafe-outputs.urlsto workflow schemaurlspolicy is preserved through imported/shared agentic workflows